package com.hmall.api.client.fallback;

import com.hmall.api.client.DemoService;
import com.hmall.api.dto.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

@Slf4j
public class DemoClientFallbackFactory implements FallbackFactory<DemoService> {
    @Override
    public DemoService create(Throwable cause) {
        return new DemoService() {
            @Override
            public String getUser() {
                log.error("调用client失败 启用fallback",cause);
                return "调用client失败 启用fallback 查询失败";
            }

            @Override
            public String save(User user) {
                return "调用client失败 启用fallback 查询失败";
            }
        };
    }
}
